void free_effect(void * eff,void * desc)
{
	if (!hge) return;
	if (eff)
	{
		if (desc!=DESC_HEFFECT)
		{
			hge->System_Log("Error free effect.Desc error.");
			return;
		}
		hge->Effect_Free((HEFFECT)eff);
	}
}
static const char pyEffect_Load_doc[]=
"Effect_Load(filename,size=0) -> HEFFECT\n"
"Loads a sound effect from memory, resource pack or disk file.";
static PyObject *
pyEffect_Load(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	const char * filename;
	int size = 0;
	if (!PyArg_ParseTuple(args,"s|i:Effect_Load",&filename,&size))
		return 0;
	HEFFECT effect = hge->Effect_Load(filename,size);
	if (!effect)
	{
		PyErr_SetString(pyHGEError,hge->System_GetErrorMessage());
		return 0;
	}
	return PyCObject_FromVoidPtrAndDesc((void*)effect,(void*)DESC_HEFFECT,free_effect);
}

static const char pyEffect_Free_doc[]=
"Effect_Free(effect) -> None\n"
"Deletes loaded sound effect and frees associated resources.";
static PyObject *
pyEffect_Free(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	PyObject * obj;
	if (!PyArg_ParseTuple(args,"O:Effect_Free",&obj))
		return 0;
	if (!PyCObject_Check(obj) || PyCObject_GetDesc(obj)!=(void*)DESC_HEFFECT)
	{
		PyErr_SetString(PyExc_TypeError,"Effect_Free(): Effect object is required.");
		return 0;
	}
	hge->Effect_Free((HEFFECT)PyCObject_AsVoidPtr(obj));
	PyCObject_SetVoidPtr(obj,0);
	Py_RETURN_NONE;
}

static const char pyEffect_Play_doc[]=
"Effect_Play(effect) -> Channel object\n"
"Starts playing a sound effect.";
static PyObject *
pyEffect_Play(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	PyObject * obj;
	if (!PyArg_ParseTuple(args,"O:Effect_Free",&obj))
		return 0;
	if (!PyCObject_Check(obj) || PyCObject_GetDesc(obj)!=(void*)DESC_HEFFECT)
	{
		PyErr_SetString(PyExc_TypeError,"Effect_Play(): Effect object is required.");
		return 0;
	}
	HCHANNEL chn = hge->Effect_Play((HEFFECT)PyCObject_AsVoidPtr(obj));
	return PyCObject_FromVoidPtrAndDesc((void*)chn,(void*)DESC_HCHANNEL,0);
}

static const char pyEffect_PlayEx_doc[]=
"Effect_PlayEx(effect,volume=100,pan=0,pitch=1.0,loop=False) -> Channel object\n"
"Starts playing a sound effect with additional parameters.";
static PyObject *
pyEffect_PlayEx(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	PyObject * obj;
	int volume=100;
	int pan=0;
	float pitch=1.0;
	PyObject *loopobj = Py_False;
	bool loop;
	int bval;
	if (!PyArg_ParseTuple(args,"O|iifO:Effect_PlayEx",&obj,&volume,&pan,&pitch,&loopobj))
		return 0;
	bval = PyObject_IsTrue(loopobj);
	if (bval == -1) return 0;
	loop = bval > 0;
	if (!PyCObject_Check(obj) || PyCObject_GetDesc(obj)!=(void*)DESC_HEFFECT)
	{
		PyErr_SetString(PyExc_TypeError,"Effect_Play(): Effect object is required.");
		return 0;
	}
	HCHANNEL chn = hge->Effect_PlayEx((HEFFECT)PyCObject_AsVoidPtr(obj),volume,pan,pitch,loop);
	return PyCObject_FromVoidPtrAndDesc((void*)chn,(void*)DESC_HCHANNEL,0);
}












